package controleur;

import model.Cours;
import model.Groupe;
import model.Seance;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import businessObjects.CoursBo;
import businessObjects.GroupeBo;
import businessObjects.SeanceBo;

import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AjaxAction extends Action {

	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		CoursBo cours = new CoursBo() ;
	
		String idCours = request.getParameter("idCours");
		System.out.println("##########################"+idCours+"###############################");
		int id = Integer.parseInt(idCours);
		System.out.println("id"+id);
		
		String resultat = "";
		
		if (id!=0) {
			resultat = "succes";
			
			Cours c = cours.getCours(id);
			
			String description = c.getDescription();
			
			request.setAttribute("description", description);
		}
		return mapping.findForward(resultat);
	}
	
}